package com.example.diethealthsystem.service;

import com.example.diethealthsystem.entity.UserHealthIndex;
import com.example.diethealthsystem.repository.UserHealthIndexRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class UserHealthIndexService {

    private final UserHealthIndexRepository userHealthIndexRepository;

    @Autowired
    public UserHealthIndexService(UserHealthIndexRepository userHealthIndexRepository) {
        this.userHealthIndexRepository = userHealthIndexRepository;
    }

    public List<UserHealthIndex> findAll() {
        return userHealthIndexRepository.findAll();
    }

    public Optional<UserHealthIndex> findById(Long id) {
        return userHealthIndexRepository.findById(id);
    }

    public UserHealthIndex save(UserHealthIndex userHealthIndex) {
        return userHealthIndexRepository.save(userHealthIndex);
    }

    public void deleteById(Long id) {
        userHealthIndexRepository.deleteById(id);
    }

    public List<UserHealthIndex> findByUserId(Long userId) {
        return userHealthIndexRepository.findByUserId(userId);
    }
} 